package suncertify.db;

/**
 * This class is a Wapper to access database file
 * 
 * @author Edson Pereira
 * @version 1.0
 */
class DataProvider {

    DataProvider(String path){
        
    }
    
    /** 
     * Reads a record from file. 
     *
     * @param recNo Record number to be read from file
     * @return Returns an array where each element is a record value
     * @throws RecordNotFoundException Indicates record number does not 
     *         exist or was marked as deleted.
     */
    public String[] read(int recNo) throws RecordNotFoundException {
        String[] result = {"change"};
        return result;
    }

    /**
     * Modifies fields of a record. 
     * <p>The new value for field n appears in data[n].
     *
     * @param recNo Record number to be read from file
     * @param data Array of {@code String} where each element is a record
     *        value
     * @param lockCookie Owner of record operation
     * @throws RecordNotFoundException Indicates record number does not exist 
     *         or marked as deleted.
     * @throws SecurityException Record is locked with a cookie other than 
     *         lockCookie.
     */
    public void update(int recNo, String[] data, long lockCookie)
            throws RecordNotFoundException, SecurityException {

    }

    /**
     * Deletes a record making the record number and associated disk storage
     * available for reuse.
     *
     * @param recNo Record number to be read from file
     * @param lockCookie Owner of record operation
     * @throws RecordNotFoundException Indicates record number does not exist 
     *         or marked as deleted.
     * @throws SecurityException Record is locked with a cookie other than 
     *         lockCookie.
     */
    public void delete(int recNo, long lockCookie)
            throws RecordNotFoundException, SecurityException {
        
    }
    
    /**
     * Search for records that match the specified criteria. 
     *
     * <p>Field {@code n} in the database file is described by criteria
     *    [{@code n}]. A null 
     * value in criteria[{@code n}] matches any field value. 
     * <p>A non-null value in criteria[{@code n}] matches any field value that
     * begins with criteria[{@code n}].
     * For example, "Fred" matches "Fred" or "Freddy".) 
     *
     * @param criteria Array of {@code String} where each element is a record
     *        value
     * @return An array of record numbers that match the specified criteria. 
     */
    public int[] find(String[] criteria) {
        return null;
    }
    
    /**
     * Creates a new record in the database
     * @param data Array of {@code String} where each element is a record
     *        value
     * @return The {@code int} record number of the new record
     * @throws DuplicateKeyException Record already created
     */
    public int create(String[] data) throws DuplicateKeyException {
        return 0;
    }
}
